import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;

public class HexServer {
	private static HexSessionManager sessionManager  = new HexSessionManager();
	public static void main(String args[]) {
		if (args.length != 2) {
			System.err.println("usage: HexServer host port");
		} else {
			
			String host = args[0];
			int port = Integer.parseInt(args[1]);
			try {
				ServerSocket connect = new ServerSocket();
				connect.bind(new InetSocketAddress(host, port));

				while (true) {
					Socket socket = connect.accept();
					ViewProxy proxy = new ViewProxy(socket);
					proxy.setViewListener(sessionManager);
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				System.exit(0);
			}
		}
	}
}
